<%-- 
  - Author: Mohtisham.Salahria
  - Date: 27-May-2011
  - Copyright Notice: TRAKHEES
  - Description: list.jsp
 --%>

<%@ include file="/WEB-INF/view/include.jsp"%>
<%@ page import="ae.pcfc.etks.online.web.*"%>


<c:choose>
	<c:when
		test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
		<script language="Javascript" type="text/javascript"
			src='<c:url value="/resources/js/jqgrid/grid.locale-ar.js"/>'></script>
	</c:when>
	<c:otherwise>
		<script language="Javascript" type="text/javascript"
			src='<c:url value="/resources/js/jqgrid/grid.locale-en.js"/>'></script>
	</c:otherwise>
</c:choose>
<script language="Javascript" type="text/javascript"
	src='<c:url value="/resources/js/jqgrid/grid.base.js"/>'></script>
<script language="Javascript" type="text/javascript"
	src='<c:url value="/resources/js/jqgrid/grid.common.js"/>'></script>
<script language="Javascript" type="text/javascript"
	src='<c:url value="/resources/js/jqgrid/grid.formedit.js"/>'></script>
<script language="Javascript" type="text/javascript"
	src='<c:url value="/resources/js/jqgrid/grid.inlinedit.js"/>'></script>

<script language="Javascript" type="text/javascript"
	src='<c:url value="/resources/js/jqgrid/grid.custom.js"/>'></script>
<script language="Javascript" type="text/javascript"
	src='<c:url value="/resources/js/jqgrid/jquery.fmatter.js"/>'></script>
<script language="Javascript" type="text/javascript"
	src='<c:url value="/resources/js/jqgrid/grid.filter.js"/>'></script>
<script language="Javascript" type="text/javascript"
	src='<c:url value="/resources/js/jqgrid/grid.jqueryui.js"/>'></script>
<script language="Javascript" type="text/javascript"
	src='<c:url value="/resources/js/jqgrid/grid.import.js"/>'></script>
<script language="Javascript" type="text/javascript"
	src='<c:url value="/resources/js/jqgrid/grid.grouping.js"/>'></script>
<script type="text/javascript">
    $.jgrid.no_legacy_api = true;
    $.jgrid.useJSON = true;
</script>

<script type="text/javascript">
$()
	.ready(
			function() {
					jQuery("#grid").jqGrid({
					 datatype :'json',
					 url		 :'${pageContext.request.contextPath}/user/internal/workflow/inbox/displayRequests.json', 
					 autowidth: true, 
					 height: 'auto', 
					 rowNum: 10, 
					 rowList: [10,20,30], 
					 colNames:['<spring:message code="label.id" />','<spring:message code="label.user.request.reference.no" />','<spring:message code="label.incident.id" />', '<spring:message code="label.process.code" />','<spring:message code="label.workflow.request.desc" />', '<spring:message code="label.workflow.request.desc" />',  '<spring:message code="label.process.step.code" />','<spring:message code="label.process.step.desc" />', '<spring:message code="label.process.step.desc" />', '<spring:message code="label.admin.action" />'],
					 colModel:[ 
								 {name:'strApplicationId',index:'strApplicationId', width:80,sortable : true},
								 {name:'strClientRefNo',index:'strClientRefNo', width:75,sortable : false},
								 {name:'strWFIncidentId',index:'strWFIncidentId', width:75,sortable : true},
								 {name:'strProcessCode',index:'strProcessCode', width:0,sortable : true, hidden: true},
								 {name:'strProcessCodeDescAr',index:'strProcessCodeDescAr', width:200,sortable : true								 
								 <c:choose>
									 <c:when test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
								 		},	 
									 </c:when>
									 <c:otherwise>
										,hidden:true},
									 </c:otherwise>
								 </c:choose>
								 {name:'strProcessCodeDescEn',index:'strProcessCodeDescEn', width:200,sortable : true
								<c:choose>
									 <c:when test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
									 	,hidden:true},	 
									 </c:when>
									 <c:otherwise>
									 	},
									 </c:otherwise>
								 </c:choose>										 
								 {name:'strProcessStep',index:'strProcessStep', width:0,sortable : true,hidden: true},
								 {name:'strProcessStepDescAr',index:'strProcessStepDescAr', width:250,sortable : true
								 <c:choose>
								 <c:when test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
							 		},	 
								 </c:when>
								 <c:otherwise>
									,hidden:true},
								 </c:otherwise>
							 </c:choose>
							  	{name:'strProcessStepDescEn',index:'strProcessStepDescEn', width:250,sortable : true
							<c:choose>
								 <c:when test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
								 	,hidden:true},	 
								 </c:when>
								 <c:otherwise>
								 	},
								 </c:otherwise>
							 </c:choose>								
								 {name:'action', sortable: false, width:75, formatter:function(){
									 var queryParams = 'appid='+arguments[2][9]+'&Incident='+arguments[2][10]+'&StepName='+arguments[2][11];
									 if(arguments[2][3] == 'NCCR'){
										 return '<a href="${pageContext.request.contextPath}/admin/workflow/general/company/request/nonclient/form.htm?'+queryParams+'" ><spring:message code="label.user.request.view"/></a>';
									}else if(arguments[2][3] == 'NCPR'){
										return '<a href="${pageContext.request.contextPath}/admin/workflow/general/person/request/nonclient/form.htm?'+queryParams+'" ><spring:message code="label.user.request.view"/></a>';
									}else if(arguments[2][3] == 'CCR'){
										return '<a href="${pageContext.request.contextPath}/admin/workflow/general/company/request/client/form.htm?'+queryParams+'" ><spring:message code="label.user.request.view"/></a>';
									}else if(arguments[2][3] == 'CPR'){
										return '<a href="${pageContext.request.contextPath}/admin/workflow/general/person/request/client/form.htm?'+queryParams+'" ><spring:message code="label.user.request.view"/></a>';
									}else if(arguments[2][3] == 'CRR'){
										return '<a href="${pageContext.request.contextPath}/admin/workflow/general/role/request/form.htm?'+queryParams+'" ><spring:message code="label.user.request.view"/></a>';
									}else if(arguments[2][3] == 'SR'){
										return '<a href="${pageContext.request.contextPath}/admin/workflow/general/service/request/form.htm?'+queryParams+'" ><spring:message code="label.user.request.view"/></a>';
									}
								      return '<a href="#"><spring:message code="label.user.request.view"/></a>';
								  }} 
								],
					pager: "#pager",
					viewrecords: true,
				 <c:choose>
					 <c:when test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
					 sortname:  'strProcessCodeDescAr', 
					 </c:when>
					 <c:otherwise>
					 sortname:  'strProcessCodeDescEn',
					 </c:otherwise>
				 </c:choose>
					grouping:true, 
					groupingView : { 
						groupField : [
										 <c:choose>
										 <c:when test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
										 'strProcessCodeDescAr' 
										 </c:when>
										 <c:otherwise>
										 'strProcessCodeDescEn'
										 </c:otherwise>
									 </c:choose>
									],
						groupColumnShow : [true],
						groupText : ['<b>{0}</b>'], 
						groupCollapse : false
					 }, 
					caption: '<spring:message code="label.inbox" />'
					<c:if test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
					, direction:'rtl'
					</c:if>	
				});
				

});
	
</script>
<div id="container" dir='<spring:message code="page.dir"/>'
	align='<spring:message code="page.align"/>'>
<%
	if(request.getAttribute(ConstantsAdmin.SUCCESS_PARAM) != null) {
%>
<script type="text/javascript">
		$(document)
				.ready(
						function() {
							jAlert(
									'success','<%=request.getAttribute(ConstantsAdmin.SUCCESS_PARAM)%>',
									'<spring:message code="msg.success" />');								
						});
	</script>			
<% }  %>


<div id="search"></div>
<table id="grid" width="100%">
</table>
<span id="pager"></span>
</div>